class Person { protected String name,city; public Person(String nm,String ct) { name=nm; city=ct; } public void showData() { System.out.println("Name is "+name); System.out.println("City is "+city); } } class Employee extends Person { protected String job; protected int salary; public Employee(String nm,String ct,String jb,int sl) { super(nm,ct); job=jb; salary=sl; } public void showData() { super.showData(); System.out.println("Job is "+job); System.out.println("Salary is "+salary); } } class demo { public static void main(String args[]) { Person a=new Person("Amit Jain","Amravati"); a.showData(); Employee b; b=new Employee("Nitin Joshi","Nagpur","Clerk",25700); b.showData(); } }
Name is Amit Jain City is Amravati Name is Nitin Joshi City is Nagpur Job is Clerk Salary is 25700